package com.hns.can.safety.service;

import com.hns.can.common.aop.orgTree.DriverInterfaceAnnotation;
import com.hns.can.common.aop.orgTree.LeftOrgAnnotation;
import com.hns.can.common.aop.sedate.SedateAnnotation;
import com.hns.can.common.service.BaseInfoValueService;
import com.hns.can.common.vo.CommonParamsVo;
import com.hns.can.common.vo.ReportSummaryVo;
import com.hns.can.safety.vo.CarFailureStatisticsVo;
import com.hns.can.safety.vo.FaultsCountsParamVo;
import com.hns.can.safety.vo.FaultsCountsVo;
import com.hns.frame.mybatis.Pagination;
import com.hns.frame.service.CommonService;
import com.hns.tool.pub.PubUtil;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 故障统计Service
 * @author:zhangzq
 * @email:
 * @version Revision 2.0.0
 */
@Service
public class FaultsCountService extends CommonService {

    @Autowired
    private BaseInfoValueService baseInfoValueService;

    /**
     * 分页查询故障统计
     * @param vo
     * @return
     * @author:zhangzq
     * @email:
     */
    @SuppressWarnings("unchecked")
    @LeftOrgAnnotation()
    @SedateAnnotation()
    @Transactional
    @DriverInterfaceAnnotation()
    public Pagination searchFaultsCount(CommonParamsVo vo) throws Exception {
        Pagination page = this.myBatisPage("faultsCount.getFaultsCountDataCount", "faultsCount.getFaultsCountData",vo,FaultsCountsVo.class);
        List list=page.getData();
        baseInfoValueService.fillOrganLineLicPltNo(list);
        page.setData(list);
        return page;
    }

    /**
     * 查询车辆故障统计
     * @param vo
     * @return
     * @author:zhangzq
     * @email:
     */
    @SuppressWarnings("unchecked")
    @LeftOrgAnnotation()
    @SedateAnnotation()
    @Transactional
    @DriverInterfaceAnnotation()
    public List<ReportSummaryVo> getCarFaultsCountData(CommonParamsVo vo) throws Exception {
        List<ReportSummaryVo> list = PubUtil.convertListMapToObject(sqlMapDao.selectList("faultsCount.getCarFaultsCountData", vo), CarFailureStatisticsVo.class);
        baseInfoValueService.fillOrganLineLicPltNo(list);
        return list;
    }

    /**
     * 查询故障统计用于导出
     * @param vo
     * @return
     * @author:zhangzq
     * @email:
     */
    @SuppressWarnings("unchecked")
    @LeftOrgAnnotation()
    @SedateAnnotation()
    @Transactional
    @DriverInterfaceAnnotation()
    public List<ReportSummaryVo> getFaultsCount(CommonParamsVo vo) throws Exception {
        List<ReportSummaryVo> list = PubUtil.convertListMapToObject(sqlMapDao.selectList("faultsCount.getFaultsCountData", vo), FaultsCountsVo.class);
        baseInfoValueService.fillOrganLineLicPltNo(list);
        return list;
    }

    /**
     * 查询故障统计用于图表
     * @param vo
     * @return
     * @author:zhangzq
     * @email:
     */
    @LeftOrgAnnotation()
    @SedateAnnotation()
    @Transactional
    @DriverInterfaceAnnotation()
    public List<ReportSummaryVo> getFaultsCountDataForChart(CommonParamsVo vo) throws Exception {
        List<ReportSummaryVo> list = PubUtil.convertListMapToObject(sqlMapDao.selectList("faultsCount.getFaultsCountDataForChart", vo), FaultsCountsVo.class);
        return list;
    }
}
